<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>活动详情</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="format-detection" content="telephone=no"/>
<meta name="format-detection" content="email=no"/>
<meta name="format-detection" content="address=no"/>
<link href="__PUBLIC__/css/base.css" rel="stylesheet"/>
</head>
<body class="huibg">
<!---  头部开始  -->
<div class="top clearfix">
	<div class="icon_left"></div>
	<div class="icon_right"></div>
</div>
<!---  头部结束  -->
<div class="fbbl join cssss">
	<div class="box">
		<div class="title_02">活动信息</div>
		<div class="box_04">
			<if condition="$event['isonline'] eq 1">
				<b>线上活动链接：</b>
				<span>{$event.eventlink}</span>
			<else />
				<b>线下活动地点：</b>
				<span>{$event.location}</span>
			</if>
		</div>
		<div class="box_04">
			<b>活动费用：</b>
			<if condition="$event.price eq 0">
				<span>免费</span>
			<else />
				<span>收费</span>
			</if>
		</div>
		<div class="box_04">
			<b>收费费用：</b>
			<span>￥{$event.price}.00</span>
		</div>
		<div class="box_04">
			<b>活动名称：</b>
			<span class="mones">{$event.name}</span>
		</div>
		<volist name="org" id="vo" key="k">
		<div class="box_04">
			<if condition="$k eq 1">
			<b>主办机构：</b>
			<span>{$vo.name}</span>
			<else />
			<b></b>
			<span>{$vo.name}</span>
			</if>
		</div>
		</volist>
		<div class="box_04">
			<b>活动期数：</b>
			<span>{$event.period}</span>			
		</div>
		<div class="box_04">
			<b>活动开始时间：</b>
			<span>{$event.starttime}</span>			
		</div>
		<div class="box_04">
			<b>活动结束时间：</b>
			<span>{$event.endtime}</span>			
		</div>
		<div class="box_04">
			<b>已参加人数：</b>
			<span>{$event['membercount'] - $event['restnums']}/{$event.membercount} 人</span>			
		</div>

	</div>
	<div class="box rebas">
		<div class="title_02 btds">报名信息</div>
		<div class="box_04">
			<b>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</b>
			<input type="text" name="name" value="{$userinfo.name}">
		</div>
		<div class="box_04">
			<b>手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机：</b>
			<input type="text" name="mobile" value="{$userinfo.mobile}" maxlength="11">
		</div>
		<div class="box_04">
			<b>工作单位：</b>
			<input type="text" name="position" value="{$userinfo.hospital}">
		</div>
		<div class="box_04">
			<b>科&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;室：</b>
			<input type="text" name="department" value="{$userinfo.department}">
		</div>
		<if condition="$event.price neq 0">
		<div class="box_04">
			<b>报名人数：</b>
			<span class="signNum2">1人</span>
			<div class="text_2">
				<i class="btn9"></i>
				<input type="text" class="signNum" value="1">
				<i class="btn10"></i>
			</div>
		</div>
		</if>
	</div>
	<div class="bott2">
		<a class="yes" id="join_act">确定参加</a>
	</div>
</div>
<!-- 支付 开始 -->
<div class="js actity_js cssss none">
	<div  class="box_06">
		<div class="title">支付费用</div>
		<div class="box_07">活动费用：<span class="mnns_one">￥<em>0</em>.00</span></div>
		<div class="box_07">报名人数：<span class="signNum3">3</span>人</div>
		<div class="box_07 box_0no">活动费用：<span class="mnns">￥<em>0</em>.00</span></div>
	</div>
	<div  class="box_06">
		<div class="title">请选择支付方式：</div>
		<div class="box_010 check wei_zhi"><span>微信支付</span><i></i></div>
	</div>
	<div  class="box_06">
		<div class="title">金豆抵用</div>
		<div class="box_07">
			<div class="text_1">当前金豆数：<span class="point_sum">{$points}</span>个</div>
		</div>
		<div class="box_07">
			<div class="text_1">使用金豆数：<span class="use_point" >0</span>个</div>
			<div class="text_2">
				<i class="jian"></i>
				<input class="pointNum" type="text" value="0" readonly="readonly"/>
				<i class="jia"></i>
			</div>
		</div>
		<div class="box_07" style="border-bottom: none;">
			<div class="text_1">使用金豆为100的整数倍</div>
			<div class="text_2">抵<span class="mons">￥<em>0</em>.00</span></div>
		</div>
	</div>
	<div class="box_06">
		<div class="box_09" style="color: #666666; font-size: 1.2rem;">实付款：<span class="payNum">￥<em>00</em>.00</span></div>
	</div>
	<div class="bott2">
		<a class="yes">确定支付</a>
	</div>
</div>
<!-- 支付 结束 -->
<!---  报名成功 提示框开始  -->
<div class="reminder_box succe none">
	<div class="reminderBox_bg"></div>
	<div class="reminderBox_text">
	</div>
</div>
<!---  报名成功 提示框结束  -->
<!---  报名成功 提示框开始  -->
<div class="reminder_box succe2 none">
	<div class="reminderBox_bg"></div>
	<div class="reminderBox_text">
		<p>亲，这么重要的活动太好了~</p>
		<p>您报名成功了，请按活动时间参与活动。如有变动会有提醒；如有问题可咨询客服。</p>
		<p class="texcen"><a class="iKnow" href="__URL__/actity_info/id/{$event.id}"><span>知道了</span></a></p>
	</div>
</div>
<!---  报名成功 提示框结束  -->
</body>
<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/js/comm.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
var nonceStr = '{$nonceStr}';
var timestamp = {$timestamp};
var signature = '{$signature}';
var id={$event.id};	
var totalNum={$event.membercount};		//可报名总人数
var restNums={$event['restnums']}; 		//剩余报名人数
var price={$event.price}; 		//价格
var signNum=$(".signNum").val();	//报名人数
signNum=parseInt(signNum);
var name;	//姓名
var mobile;	//手机
var position;	//工作单位
var department;	//科室
var detail=[{}];
var fee;
var points=0;
var totalfee=price*signNum;//总钱数
totalfee=parseInt(totalfee);
var paytype;//付款类型
var pointNum=0;//抵扣金豆数
var payNum;//应付钱数
var mons=0;;//抵扣钱数
var point_sum;//当前金豆数
//报名人数 加
$(".btn10").click(function(){
	if(signNum>=restNums){
		alert("名额已满");
		return;
	}else{
		signNum+=1;
		$(".signNum").val(signNum);
		$(".signNum2").html(signNum+"人");
	}
});
//报名人数 减
$(".btn9").click(function(){
	if(signNum==1){
		alert("至少一人报名");
		return;
	}else{
		signNum-=1;
		//restNums-=1;
		$(".signNum").val(signNum);
		$(".signNum2").html(signNum+"人");
	}
});
//确定参加
$("#join_act").click(function(){
	check();
	if(price == 0){
		$.post('__URL__/actity_join',{
			id:id,
			name:name,
			mobile:mobile,
			hospital:position,
			department:department,
		},function(e){
			if(e.status==1){
				$(".succe2").removeClass("none");
			}else{
				alert(e.msg);
			}		
		});
	}else{
		paytype=5;
		totalfee=price*signNum;
		$(".mnns_one em").html(price);
		$(".signNum3").html(signNum);
		$(".mnns em").html(totalfee);		
		$(".join").addClass("none");
		$(".payNum em").html(totalfee);
		$(".actity_js").removeClass("none");
	}

});
function check(){
	name=$.trim($(".join input[name='name']").val());
	mobile=$.trim($(".join input[name='mobile']").val());
	position=$.trim($(".join input[name='position']").val());
	department=$.trim($(".join input[name='department']").val());
	
	if((name.length<1) || (name.length>5)){
		alert("请正确输入姓名");
		return;
	}
	var isMobile=/^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/;
	if((mobile.length<1) || !isMobile.test(mobile)){
		alert("请正确输入手机号码");
		return;
	}
	if(position.length<1){
		alert("请输入工作单位");
		return;
	}
	if(department.length<1){
		alert("请输入科室");
		return;
	}
}
//加
$(".jia").click(function(){	
	point_sum=parseInt($(".point_sum").html());
	mons=parseInt($(".mons em").html());
	if(totalfee==0){
		alert("金豆数量已够");
		return;
	}
	if(point_sum<100){
		alert("金豆数量不够");
		return;
	}else{
		pointNum+=100;
		$(".pointNum").val(pointNum);
	}	
	totalfee-=1;
	mons=parseInt(pointNum/100);
	point_sum=parseInt(point_sum)-100;	
	payNum=totalfee;
	points=pointNum;
	$(".use_point").html(pointNum);	
	$(".point_sum").html(point_sum);
	$(".mons em").html(mons);
	$(".payNum em").html(payNum);	
});
//减
$(".jian").click(function(){
	point_sum=parseInt($(".point_sum").html());
	mons=parseInt($(".mons em").html());		
	if(pointNum<1){
		alert("金豆数已经为0");
		return;
	}	
	pointNum-=100;
	totalfee+=1;
	mons=parseInt(pointNum/100);
	point_sum=parseInt(point_sum)+100;	
	payNum=totalfee+mons;
	points=pointNum;
	$(".use_point").html(points);	
	$(".point_sum").html(point_sum);
	$(".mons em").html(mons);
	$(".payNum em").html(totalfee);
	$(".pointNum").val(pointNum);
	
});
//选择微信支付
$(".wei_zhi").click(function(){
	if ($(this).hasClass("check")) {
		$(this).removeClass("check");
	}else{
		$(this).addClass("check");
	}
});
//购买  确定支付
var regFlag = true;
$(".js .yes").click(function(){
	if(!regFlag) {
		return;
	}
	detail=[{"id":id,"fee":price,"points":points,"name":name,"hospital":position,"department":department,"mobile":mobile,"nums":signNum}];//活动的ID
	if($(".wei_zhi").hasClass("check")){
		regFlag = false;
		detail=JSON.stringify(detail);
		$.post('__URL__/wxPay',{
			nonceStr:nonceStr,
			timestamp:timestamp,
			signature:signature,
			paytype:paytype,
			totalfee:totalfee,
			points:points,
			detail:detail,
			tips: "joinConfirm_text"
		},function(e){
			regFlag = true;
			$(".succe").removeClass("none");
			$(".succe .reminderBox_text").html(e);
		});
		
	}else{
		alert("请选择支付方式");
		return;
	}	
});
</script>
</html>